<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateActivityTriggersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('activity_triggers', function (Blueprint $table) {
            $table->uuid('id')->index();
            $table->uuid('user_id')->comment("用户id");
            $table->string('rule_name')->comment("规则名称");
            $table->string('act_id')->default("0")->comment("关联活动id");
            $table->string('act_name')->comment("关联活动");
            $table->integer('act_type')->comment("活动类型 1-列表活动 2-自有活动");
            $table->integer('platform')->comment("触发平台 （二进制存储 1-JS 2-iOS 4-Android）");
            $table->string('show_img')->default(1)->comment("触发形式 1-小图 2-大图 3-无图");
            $table->string('small_img')->nullable()->comment("小图");
            $table->string('big_img')->nullable()->comment("大图");
            $table->string('checked_big_img')->nullable()->comment("选中的大图");
            $table->string('checked_small_img')->nullable()->comment("选中的小图");
            $table->integer('begin_time')->comment("触发开始时间");
            $table->integer('end_time')->comment("触发结束时间");
            $table->integer('trigger_times')->comment("触发次数");
            $table->integer('trigger_times_unit')->comment("触发次数单位 1-活动全程 2-每天");
            $table->integer('trigger_condition')->comment("触发条件 1-登录 2-注册 3-支付 4-启动");
            $table->integer('target')->comment("触发用户 1-所有用户 2-性别 3-省份");
            $table->smallInteger('status')->default(2)->comment("状态 1-进行中 2-已暂停");
            $table->integer('weight')->default(1)->comment("优先级");
            $table->integer('totop')->default(0)->nullable()->comment("距上边百分比");
            $table->integer('toleft')->default(0)->nullable()->comment("距左边百分比");
            $table->integer('float_time')->default(0)->comment("悬浮时间");
            $table->integer('float_type')->default(1)->comment("悬浮类型 1:一直存在 2:定时消失");
            $table->smallInteger('big_img_number')->default(0)->comment("默认显示第几张大图片");
            $table->smallInteger('small_img_number')->default(0)->comment("默认显示第几张小图片");

            $table->timestamps();
            $table->primary('id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('activity_triggers', function (Blueprint $table) {
            $table->dropIfExists();
        });
    }
}
